// 引入插件
import Vue from 'vue'
import Vuex from 'vuex'

// 引入接口
import { reqGetSearchData } from '@/api/index'
// 注册插件
Vue.use(Vuex)


// 定义方法
const state = {
    searchList: [],//总数据
    attrsList: [],// 属性列表
    goodsList: [], // 商品列表
    trademarkList: [] // 品牌

}
const actions = {

    // 获取数据
    async getSearchList({ commit }, query) {
        const result = await reqGetSearchData(query)
        if (result.code === 200) {
            commit('SetSearchList', result.data)
        } else {
            console.log(result.message);
        }
    },

}
const mutations = {
    // 保存数据
    SetSearchList(state, data) {
        // console.log(data);
        state.searchList = data
        state.attrsList = data.attrsList
        state.goodsList = data.goodsList
        state.trademarkList = data.trademarkList
    }

}
const getters = {}


export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}

